import {
	UPDATEMOBILE,
	UPDATEPAGE,
    CHECKREAD,
    UPDATERZ,
    UPDATERZINFOR,
    UPDATESJTITLE,
    UPDATERZTITLE,
    UPDATECURRENTUSER,
    UPDATENOTICE
} from './mutation_type'

export default {
	[UPDATEMOBILE](state, mobile) {
        state.mobile = mobile
        state.worked_mobile = mobile.substr(0, 3) + '*****' + mobile.substr(8)
        state.hasMobile = true;
        state.navList[1].name = mobile
	},
	[UPDATEPAGE](state) {
		state.page++
	},
	[CHECKREAD](state) {
		//检查有没有未读的
		var len = state.messageList.length;
        var n = 0;
		for (var i = 0; i < len; i++) {
			if (state.messageList[i].isread == 0) {
				state.viewed = false;
				break;
			} else {
				n++;
			}
		}
		if (n == len) {
			state.viewed = true;
		}
    },
    [UPDATERZ](state, value) {
        state.yrz = value
    },
    [UPDATERZINFOR](state, obj){
        state.user_name = obj.name;
        state.user_idno = obj.id;
    },
    [UPDATERZTITLE](state){
        state.navList[2].name = '已实名认证'
    },
    [UPDATESJTITLE](state, value){
        state.navList[1].name = value
    },
    [UPDATECURRENTUSER](state){
        state.currentUser = '未设置昵称'
    },
    [UPDATENOTICE](state, obj) {
        state.notice = obj;
    }
}
